using System.Collections;
using UnityEngine;

public class MessageDisplay : MonoBehaviour
{
	public UILabel label;

	public UISprite bck;

	protected float bckAlpha;

	public void Awake()
	{
		bckAlpha = 0.67578125f;
	}

	public void TweenMessage(string message)
	{
		StopAllCoroutines();
		base.gameObject.SetActive(true);
		UITools.ChangeText(label, message);
		StartCoroutine(DoShowMessage());
	}

	public IEnumerator DoShowMessage()
	{
		label.alpha = 0f;
		bck.alpha = 0f;
		float inDuration = 0.2f;
		float display = 2f;
		TweenAlpha.Begin(label.cachedGameObject, inDuration, 1f);
		TweenAlpha.Begin(bck.cachedGameObject, inDuration, bckAlpha);
		yield return new WaitForSeconds(inDuration + display);
		TweenAlpha.Begin(label.cachedGameObject, inDuration, 0f);
		TweenAlpha.Begin(bck.cachedGameObject, inDuration, 0f);
		yield return new WaitForSeconds(inDuration);
		base.gameObject.SetActive(false);
	}
}
